package ShenBlueInc.Center;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;

import ShenBlueDao.CreditCardDao;
import ShenBlueInc.Sql.Card_inc;

public class Card_Center {
	Card_inc inc=new Card_inc();
	/**
	 * 增加信用卡
	 * @param id
	 * @param card_id
	 * @param time
	 * @param Bank_id
	 * @return
	 */
	public boolean Add_Card(String id,String card_id,String time,String Bank_id) {
		if(inc.Add_Card(id, card_id, time, Bank_id)<1) {
			return true;
		}
		return false;
	}
	/**
	 * 查询是否存在指定信用卡
	 * @param id
	 * @param card_id
	 * @return
	 */
	public boolean SelectCardID(String id,String card_id) {
		if(inc.SelectCardID(id, card_id)>0) {
			return true;
		}
		return false;
	}
	/**
	 * 标记还款
	 * @param user_id
	 * @param card_id
	 * @return
	 */
	public boolean TipsCardRepay(String user_id,String card_id) {
		if(inc.TipsCardRepay(user_id, card_id)<1) {
			return true;
		}
		return false;
	}
	/**
	 * 查询指定日期内还款的信用卡
	 * @param user_id
	 * @param page
	 * @param limit
	 * @return
	 */
	public LinkedList<CreditCardDao> TipsCrad(String user_id,String page,String limit) {
		LinkedList<CreditCardDao> list=new LinkedList<CreditCardDao>();
		ResultSet rs=inc.TipsCrad(user_id,page,limit);
		try {
			while(rs.next()) {
				CreditCardDao Dao=new CreditCardDao(rs.getString(1),rs.getString(2),rs.getString(3));
				list.add(Dao);
			}
			return list;
		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return null;
	}
	/**
	 * 返回需要提醒的银行卡的总数
	 * @param user_id
	 * @return
	 */
	public int TipsCradCount(String user_id) {
		return inc.TipsCradCount(user_id);
	}
	/**
	 * 返回指定条件下的银行卡
	 * @param page
	 * @param limit
	 * @param user_id
	 * @param card_id
	 * @param time_start
	 * @param time_end
	 * @param bank_id
	 * @return
	 */
	public LinkedList<CreditCardDao> ServiceCard(String page,String limit,String user_id,String card_id,String time_start,String time_end,String bank_id){
		LinkedList<CreditCardDao> list=new LinkedList<CreditCardDao>();
		ResultSet rs=inc.ServiceCard(page, limit, user_id, card_id, time_start, time_end, bank_id);
		try {
			while(rs.next()) {
				CreditCardDao Dao=new CreditCardDao(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4));
				list.add(Dao);
			}
			return list;
		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return null;
	}
	/**
	 * 返回查询数据的总值
	 * @param user_id
	 * @param card_id
	 * @param time_start
	 * @param time_end
	 * @param bank_id
	 * @return
	 */
	public int ServiceCardCount(String user_id,String card_id,String time_start,String time_end,String bank_id) {
		return inc.ServiceCardCount(user_id, card_id, time_start, time_end, bank_id);
	}
	
	public CreditCardDao CardMsg(String user_id,String id) {
		Object[] obj=inc.CardMsg(user_id, id);
		CreditCardDao Dao=new CreditCardDao();
		Dao.CreditCardDao1(obj[0].toString(), obj[1].toString(), obj[2].toString(), obj[3].toString());
		return Dao;
	}
	/**
	 * 判断是否成功修改数据
	 * @param user_id
	 * @param id
	 * @param time
	 * @param bank
	 * @return
	 */
	public boolean ModifyCreditCard(String user_id,String id,String time,String bank) {
		if(inc.ModifyCreditCard(user_id, id, time, bank)<1) {
			return true;
		}
		return false;
	}
	/**
	 * 删除指定的内容
	 * @param user_id
	 * @param card_id
	 * @return
	 */
	public boolean DelCreditCard(String user_id,String card_id) {
		if(inc.DelCreditCard(user_id, card_id)<1) {
			return true;
		}
		return false;
	}
}
